#define	the config
CC = gcc
SHELL = /bin/sh
RM = rm -f
CFLAGS := -Wall -Werror
CFAGS := -g
LDFLAGS = -lm 

#define the file
ifndef SRC
SRC := test.c
endif

OBJS := $(SRC:.c=.o)
TARGET = test
LIBS = ../lib/lib.a
FILE_TYPE = *.exe *.o *.d $(TARGET)

#define	the command
.PPHONY: all objs clean cleanobj debug

all:$(OBJS) ${LIBS}  
	@echo "creating" $(TARGET).exe
	${CC} -o ${TARGET} ${CFLAGS} ${CFAGS} $^

clean: libclean
	@echo "deleting" $(FILE_TYPE)
	@$(RM) $(FILE_TYPE)

$(OBJS):
	@echo "creating" ${OBJS}
	@${CC} -c ${SRC} -o ${OBJS}

cleanobj:
	@$(RM) *.o *.d
#---------------------------------
${LIBS}:
	@$(MAKE) -f lib.mk --no-print-directory -C ../lib all
	
libclean:
	@$(MAKE) -f lib.mk --no-print-directory -C ../lib clean
	

debug:
	@echo $(SRC)

	
	

